-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix wrap-content-type for requests of directories #452
Conversation
Thanks. First, can you remove 34a15b6, as that's not strictly related to the purpose of the PR. Second, I think I need to consider the best way to go about this. Pulling the file extension from File response bodies is useful, but in production most statically served pages will be resources. |
Ok. I am curious as to why you wouldn't want this small improvement in that same function, but it's your call 🙂
What's your hesitation exactly? My thinking is that in general, when you're serving something different than requested for whatever reason, the mime type should be the real mime type of what you're serving, not what was being requested. I mean, the Let me know if I can help! For now I think I'm going to run a modified copy of the middleware, as I need a solution, but I'm of course still motivated to contribute a solution here. |
It's good practice to ensure that a pull request contains only code related to the feature or fix being implemented. That way the diff is clean; any line that's changed relates to the pull request. Formatting changes should be separated out into another commit, and also should ensure that the codebase is consistent. That is, if you decide to replace
This change produces inconsistent behaviour when dealing with files on the filesystem, and resources located in jars. This can lead to subtle errors between development and production. For example, suppose you use the The solution I'm considering is to allow |
When the request points to a directory and the body of the response is a file (i.e. index.html or something like that), take the mime type of that file. This fixes the case where previously requesting "/" would serve "index.html" with content type "application/octet-stream".
Maybe that's not actually a problem, as |
You got me thinking with that remark by the way. I am now approaching the point that I'll be deploying this to production for the first time. I'm now converting my code to use I guess this removes the need for the change for me. I'll leave it up to you if we proceed with it anyway, or close it for now... |
Ah, you're right. Though it might be nice if that were an option. Let me think about it. |
Faced the same problem. Does this PR still under consideration? |
Just bumped into this too! I hope this gets fixed because pedestal uses the wrappers around ring's file / resource / content-type middleware as default interceptors |
Could you give a little more information on what the exact issue you had? Would it be fixed by looking for |
My exact issue is that when using This happens because This in turn leads to static files being downloaded and not served by the browser when visiting index paths. |
0d7f29a
to
0103527
Compare
Revisiting the same issue after almost a year, any considerations on merging this? |
I think my earlier comment is the best solution I can think of:
Implementing this just for files would produce inconsistent behaviour in |
Ah yeah, this seems a reasonable solution |
Fixed by a66fe9e |
When the request points to a directory and the body of the response is a file (i.e. index.html or something like that), take the mime type of that file. This fixes the case where previously requesting "/" would serve "index.html" with content type "application/octet-stream".
This fixes #408.